Skip to content

fix(selfhost): refresh stale connection tools concurrently and expose EXECUTOR_TOOLS_SYNC_TTL_MS - #1560

Merged
RhysSullivan merged 5 commits into
UsefulSoftwareCo:mainfrom
Adityakk9031:fix/sync-stale-connection-tools
Aug 28, 2026
Merged

fix(selfhost): refresh stale connection tools concurrently and expose EXECUTOR_TOOLS_SYNC_TTL_MS#1560
RhysSullivan merged 5 commits into
UsefulSoftwareCo:mainfrom
Adityakk9031:fix/sync-stale-connection-tools

Conversation

@Adityakk9031

Copy link
Copy Markdown
Contributor

Fixes #1519

  1. Concurrent Catalog Refresh: Refactored syncStaleConnectionTools in packages/core/sdk to collect connection sync tasks and execute them concurrently via Effect.all(tasks, { concurrency: 10 }) instead of sequentially awaiting them in a for...of loop.
  2. Expose EXECUTOR_TOOLS_SYNC_TTL_MS Config:
    • Extended HostConfigShape in packages/core/api with toolsSyncTtlMs and forwarded it to createExecutor.
    • Added parsing for EXECUTOR_TOOLS_SYNC_TTL_MS in apps/host-selfhost/src/config.ts ("0", "false", or "null" to disable automatic background catalog re-syncing, or a custom interval in ms).
    • Wired toolsSyncTtlMs in SelfHostHostConfig and added unit tests in apps/host-selfhost/src/executor-config.test.ts.

@Adityakk9031
Adityakk9031 force-pushed the fix/sync-stale-connection-tools branch from 67d03d9 to 5c37b31 Compare August 10, 2026 12:00
@Adityakk9031

Copy link
Copy Markdown
Contributor Author

@RhysSullivan have a look

Fail at boot on an unparseable or negative EXECUTOR_TOOLS_SYNC_TTL_MS
instead of falling back to the default. 0 keeps meaning disabled, now
spelled out in the env var's docs and mapped explicitly onto the SDK's
null sentinel, since a TTL of 0 means the opposite to the SDK.

Type the rebuild list, name the concurrency bound, and add the
regression test the concurrency change was missing: a latched MCP
fixture that only answers once the whole stale set is in flight, so a
serial refresh cannot complete.
…builds

The stale-catalog refresh rebuilds several connections at once. Each rebuild
ends in a catalog-replacement transaction, and a self-host database is one
connection issuing raw BEGIN/COMMIT, so overlapping rebuilds could reopen the
transaction collision fixed for same-connection refreshes. Split the phases:
upstream discovery stays concurrent at the existing bound, while every catalog
write takes a single permit and commits in turn.

A rebuild that fails now logs a warning with the connection and the reason,
including the cause a plain structural render would drop. The read still
succeeds on the stale-but-working catalog and the other rebuilds still finish.

Refuse a tools-sync TTL that is not a safe integer, since a larger value
silently rounds, and accept the disable tokens in any case.

Tests cover the concurrency bound (an extra connection waits while the bound is
saturated), non-overlapping persistence observed through real transactions, and
a failed rebuild that warns without failing the read.
@RhysSullivan
RhysSullivan merged commit 8c20c33 into UsefulSoftwareCo:main Aug 28, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-host tools/list blocks on sequential stale remote catalog refresh

2 participants